-
-
Notifications
You must be signed in to change notification settings - Fork 362
feat(Table): add ReloadColumnVisibleFromBrowserAsync method #7011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for your PR, @braia123. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Reviewer's GuideThis PR adds per-table persistence of column visibility by converting internal visibility reset methods to async, reading and writing visibility states to localStorage keyed by ClientTableName, and updating related method calls and samples accordingly. Sequence diagram for persisting column visibility to localStoragesequenceDiagram
participant TableComponent
participant JSRuntime
participant localStorage
TableComponent->>JSRuntime: InvokeVoidAsync("localStorage.setItem", key, value)
JSRuntime->>localStorage: setItem(key, value)
localStorage-->>JSRuntime: (stores value)
JSRuntime-->>TableComponent: (async complete)
Sequence diagram for restoring column visibility from localStoragesequenceDiagram
participant TableComponent
participant JSRuntime
participant localStorage
TableComponent->>JSRuntime: InvokeAsync("localStorage.getItem", key)
JSRuntime->>localStorage: getItem(key)
localStorage-->>JSRuntime: value
JSRuntime-->>TableComponent: value
TableComponent->>TableComponent: Deserialize value
TableComponent->>TableComponent: Apply visibility to columns
Entity relationship diagram for persisted column visibility dataerDiagram
TABLE {
string ClientTableName
bool ShowColumnList
}
COLUMN_VISIBLE_ITEM {
string Name
bool Visible
string DisplayName
}
TABLE ||--o{ COLUMN_VISIBLE_ITEM : has
LOCAL_STORAGE {
string key
string value_JSON
}
TABLE ||--o{ LOCAL_STORAGE : persists visibility
Class diagram for updated Table component column visibility logicclassDiagram
class Table {
+ClientTableName : string
+ShowColumnList : bool
+Columns : List<ITableColumn>
+_visibleColumns : List<ColumnVisibleItem>
+ResetVisibleColumns(columns)
+InternalResetVisibleColumns(columns, items)
+OnToggleColumnVisible(columnName, visible)
}
class ColumnVisibleItem {
+Name : string
+Visible : bool
+DisplayName : string
}
Table o-- "*" ColumnVisibleItem : manages
Table --> JSRuntime : uses
JSRuntime --> localStorage : interacts
Table --> ColumnVisibleItem : serializes/deserializes
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- There's a typo in the localStorage key ("bb-table-column-visiable-…")—consider renaming it to use the correct spelling ("visible") to avoid confusion.
- You changed several public methods (ResetVisibleColumns, InternalResetVisibleColumns, ResetDynamicContext) from void to async Task; this is a breaking API change—consider preserving backward‐compatible overloads or clearly documenting the version bump.
- The catch around JsonSerializer.Deserialize swallows all errors silently; you should at least log the exception or handle specific failure cases to aid debugging.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- There's a typo in the localStorage key ("bb-table-column-visiable-…")—consider renaming it to use the correct spelling ("visible") to avoid confusion.
- You changed several public methods (ResetVisibleColumns, InternalResetVisibleColumns, ResetDynamicContext) from void to async Task; this is a breaking API change—consider preserving backward‐compatible overloads or clearly documenting the version bump.
- The catch around JsonSerializer.Deserialize swallows all errors silently; you should at least log the exception or handle specific failure cases to aid debugging.
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor/Components/Table/Table.razor.cs:1261` </location>
<code_context>
}
- private void InternalResetVisibleColumns(List<ITableColumn> columns, IEnumerable<ColumnVisibleItem>? items = null)
+ private async Task InternalResetVisibleColumns(List<ITableColumn> columns, IEnumerable<ColumnVisibleItem>? items = null)
{
var cols = columns.Select(i => new ColumnVisibleItem(i.GetFieldName(), i.GetVisible()) { DisplayName = i.GetDisplayName() }).ToList();
</code_context>
<issue_to_address>
**suggestion:** Consider handling deserialization exceptions explicitly for better error tracking.
Leaving the catch block empty can hide deserialization errors. Consider logging or reporting exceptions to aid debugging.
</issue_to_address>
### Comment 2
<location> `src/BootstrapBlazor/Components/Table/Table.razor.Checkbox.cs:162` </location>
<code_context>
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
+using System.Text.Json;
+
namespace BootstrapBlazor.Components;
</code_context>
<issue_to_address>
**suggestion:** Check for consistency in serialization options between saving and loading column visibility.
Serialization should use _serializerOption to ensure compatibility with deserialization and prevent potential mismatches.
```suggestion
await JSRuntime.InvokeVoidAsync("localStorage.setItem", "bb-table-column-visiable-"+ClientTableName, JsonSerializer.Serialize(_visibleColumns, _serializerOption) ?? "");
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7011 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 742 743 +1
Lines 32398 32451 +53
Branches 4485 4495 +10
=========================================
+ Hits 32398 32451 +53
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-Authored-By: braia123 <[email protected]>
Link issues
fixes #7010
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Persist and restore BootstrapBlazor table column visibility settings using browser localStorage keyed by ClientTableName and refactor related methods to async to support storage operations
New Features:
Enhancements:
Documentation: